#ifndef UART_H
#define UART_H

#include "system_config.h"
#include "device.h"



#define ONESTOPBIT			1
#define TWOSTOPBIT			2

#define PARITY_NONE		0
#define PARITY_ODD		1
#define PARITY_EVEN		2


#if defined(HAS_UART) && !defined(HAS_UART0) && !defined(HAS_UART1) && !defined(HAS_UART2) && !defined(HAS_UART3)
#define				HAS_UART0
#define				uart_init(baudrate,stopbit,parity)			uart0_init(baudrate,stopbit,parity)
#define				uart_read(buffer,len)										uart0_read(buffer,len)
#define				uart_write(buffer,len)									uart0_write(buffer,len)
#define				uart_close()														uart0_close()
#define				INTERRUPT_VECTOR_TIMER0									INTERRUPT_VECTOR_TIMER
#endif


#ifdef HAS_UART0
void 					uart0_init(unsigned long baudrate, unsigned char stopbit, unsigned char parity);
unsigned char uart0_read(unsigned char *buffer, unsigned char len);
void 					uart0_write(unsigned char *buffer, unsigned char len);
void 					uart0_close();
#endif

#ifdef HAS_UART1
void 					uart1_init(unsigned long baudrate, unsigned char stopbit, unsigned char parity);
unsigned char uart1_read(unsigned char *buffer, unsigned char len);
void 					uart1_write(unsigned char *buffer, unsigned char len);
void 					uart1_close();
#endif

#ifdef HAS_UART2
void 					uart2_init(unsigned long baudrate, unsigned char stopbit, unsigned char parity);
unsigned char uart2_read(unsigned char *buffer, unsigned char len);
void 					uart2_write(unsigned char *buffer, unsigned char len);
void 					uart2_close();
#endif

#ifdef HAS_UART3
void 					uart3_init(unsigned long baudrate, unsigned char stopbit, unsigned char parity);
unsigned char uart3_read(unsigned char *buffer, unsigned char len);
void 					uart3_write(unsigned char *buffer, unsigned char len);
void 					uart3_close();
#endif



#endif //UART_H